// createStore 创建store实例的方法
// applyMiddleware，增强store处理action的类型
// combineReducers 合并多个数据模块的 reducers
import { createStore, applyMiddleware, combineReducers } from 'redux';

// 把store中数据显示到浏览器插件上
import { composeWithDevTools } from 'redux-devtools-extension';
// 处理函数形式action的中间件
import thunk from 'redux-thunk';

// 合并项目reducer
import { todos } from './reducers/todos';
const rootReducer = combineReducers({ todos });

// 导出store
export const store = createStore(
  rootReducer,
  composeWithDevTools(applyMiddleware(thunk))
);

// 动态计算RootState
export type RootState = ReturnType<typeof store.getState>;
